﻿using Sidvall.UI.Dialogs;
using System.Threading.Tasks;
using System.Windows;

namespace Sidvall.UI.Wpf.Dialogs
{
    public partial class MessageDialog : Window
    {
        #region Public Members

        #region ShowAsync

        public Task ShowAsync(MessageContext message, object owner)
        {
            this.MessageControl.InitializeContext(message);
            this.Title = message.Title;
            WindowManager.SetWindowOwner(this, owner);
            ShowDialog();
            return Task.FromResult(true);
        }

        #endregion

        #endregion
        #region Events

        #region MessageControl_AnswerSelected

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        private void MessageControl_AnswerSelected(object sender, System.EventArgs e)
        {
            Close();
        }

        #endregion

        #endregion
        #region Constructors

        public MessageDialog()
        {
            InitializeComponent();

            Sidvall.UI.Wpf.ControlManager.SetLanguage(this);
        }

        #endregion
    }
}
